home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Light ROM 1
/
LIGHT-ROM 1 (Amiga Library Services)(1994).iso
/
ffdisks
/
d884.lha
/
P-Compress
/
Object
/
decrunch.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-07-16
|
1KB
|
59 lines
#include "exec/types.h"
#include "exec/memory.h"
#include "libraries/dosextens.h"
#include "libraries/dos.h"
#include "stdio.h"
main(argc,argv)
int argc ;
char *argv[] ;
{
struct FileHandle *fi, *fo ;
int result ;
char header[4] ;
if (argc < 3)
{ puts (" Usage: Comp [input file] [output file]\n") ;
exit(NULL) ;
}
if ((fi = (struct FileHandle *)Open(argv[1], MODE_OLDFILE)) == 0)
{
puts ("Can't open input file\n") ;
exit (NULL) ;
}
Read(fi, header, 4) ;
if ((header[0] == 'P') && (header[1] == 'R') && (header[2] == 'E')) ;
else Seek (fi, -4, 0) ;
Read(fi, header, 2) ;
if ((header[0] != 'L') || (header[1] != 'H'))
{
puts ("File not compressed\n");
Close (fi) ;
exit(NULL) ;
}
if ((fo = (struct FileHandle *)Open(argv[2], MODE_NEWFILE)) == 0)
{
puts ("Can't open output file\n") ;
Close (fi) ;
exit (NULL) ;
}
result = decompress (fi, fo) ;
Close (fi) ;
Close (fo) ;
if (result == 1) puts ("Decompression failed\n") ;
else if (result == 2) puts ("Out of memory\n") ;
exit(NULL) ;
}